/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { HasItemInArray } from './HasItemInArray.js';
import { IsEqual } from '../core/IsEqual.js';
export class ArrayMatching {
    /**
     * Creates a matcher for arrays that matches when the examined array contains at least one item
     * that is matched by the specified <code>elementMatcher</code>.  Whilst matching, the traversal
     * of the examined array will stop as soon as a matching element is found.
     * For example:
     * <pre>assertThat(new String[] {"foo", "bar"}, hasItemInArray(startsWith("ba")))</pre>
     *
     * @param <T>
     *     the matcher type.
     * @param elementMatcher
     *     the matcher to apply to elements in examined arrays
     * @return The matcher.
     */
    static hasItemInArrayMatcher(elementMatcher) {
        return new HasItemInArray(elementMatcher);
    }
    /**
     * A shortcut to the frequently used <code>hasItemInArray(equalTo(x))</code>.
     * For example:
     * <pre>assertThat(hasItemInArray(x))</pre>
     * instead of:
     * <pre>assertThat(hasItemInArray(equalTo(x)))</pre>
     *
     * @param <T>
     *     the matcher type.
     * @param element
     *     the element that should be present in examined arrays
     * @return The matcher.
     */
    static hasItemInArray(element) {
        return this.hasItemInArrayMatcher(IsEqual.equalTo(element));
    }
}
